package rbfnn;

import java.util.List;

public class FCM {
	public List<Training> Trainings;
	public List<Center> Centers;
	
	public FCM(List<Center> _Centers, List<Training> _Trainings)
	{
		this.Centers = _Centers;
		this.Trainings = _Trainings;
	}
	
	/*
	 * Membership Degree
	 * uik = 1 / Sigma j=1 to c ( ||yk - ui|| / ||yk - uj|| ) ^ ( 2 / (m-1) )
	 * uik = Membership degree
	 * yk = Output training
	 * c = Number of cluster
	 * u = Output center
	 * m = Fuzziness Parameter
	 * */
	
	/*public void CountMembership(int m)
	{
		double Sum = 0.0;
		for(int k = 0; k < this.Trainings.size(); k++)
		{
			for(int i = 0; i < this.Centers.size(); i++)
			{
				for(int j = 0; j < this.Centers.size(); j++)
				{
					Sum = Sum + Math.pow( (this.Trainings.get(k).Output.Value - this.Centers.get(i).OutputCenter) / (this.Trainings.get(k).Output.Value - this.Centers.get(j).OutputCenter), 2 / (m-1));
					//System.out.println("(" + this.Trainings.get(k).Output.Value + " - " + this.Centers.get(i).OutputCenter + ") / (" + this.Trainings.get(k).Output.Value + " - " + this.Centers.get(j).OutputCenter + ")");
				}
				this.Trainings.get(k).Output.MembershipDegrees.add(1 / Sum);
				System.out.println("Data " + k + " to center " + i + " = " + this.Trainings.get(k).Output.MembershipDegrees.get(i));
				Sum = 0.0;
				//System.out.println("Data " + k + " to center " + i + " = " + this.Trainings.get(k).Output.Value);
			}
		}
	}*/

	/*
	 * Update Output Center
	 * ui = Sigma k=1 to n (uik) ^ m*yk / Sigma k=1 to n (uik) ^ m
	 * */
	
	/*public void UpdateCenter(int m)
	{
		double Sum = 0.0, Sum2 = 0.0;
		for(int i = 0; i < this.Centers.size(); i++)
		{
			for(int k = 0; k < this.Trainings.size(); k++)
			{
				Sum2 = Sum2 + Math.pow(this.Trainings.get(k).Output.MembershipDegrees.get(i), m);
				Sum = Sum + Sum2 * this.Trainings.get(k).Output.Value;
			}
			this.Centers.get(i).OutputCenter = Sum / Sum2;
			Sum = 0.0; Sum2 = 0.0;
		}
	}*/
}
